#!/bin/sh
#
#  Author: ng
#

STATIC_SERVER=http://corsixth-for-android.googlecode.com/files/

set -e

function fail()
{
    echo $1 >&1
    exit 1
}


[ -x jni ] || fail "invalid folder!"

cd jni

# LUA
echo "Downloading LUA..."
wget ${STATIC_SERVER}/lua-5.1.4.tar.gz
tar fxz lua-5.1.4.tar.gz
cd lua-5.1.4
wget ${STATIC_SERVER}/lua-5.1.4-android.patch
patch -p1 < lua-5.1.4-android.patch
cd ..
mv lua-5.1.4 lua
rm lua-5.1.4.tar.gz
cp -f lua.mk lua/Android.mk

# LUA JIT
echo "Downloading LUA JIT..."
wget ${STATIC_SERVER}/LuaJIT_2beta8_android.tar.gz
tar fxz LuaJIT_2beta8_android.tar.gz
rm LuaJIT_2beta8_android.tar.gz

# SDL
echo "Downloading SDL..."
wget ${STATIC_SERVER}/SDL-1.3.tar.gz
tar fxz SDL-1.3.tar.gz
mv SDL-1.3.0-5605 SDL
rm SDL-1.3.tar.gz
cp -f SDL.mk SDL/Android.mk

